// request就是axios()
import request from '../utils/request'
import { getToken } from '../utils/localData'
export const userLoginAPI = (data) => {
  // GET传参是params，POST是data
  return request({
    method: 'POST',
    url: '/login',
    //post请求 通过data传参
    data: data
  })
}

// 注册
export const userRegisterAPI = (data) => {
  // GET传参是params，POST是data
  return request({
    method: 'POST',
    url: '/register',
    //post请求 通过data传参
    data: data
  })
}
// 用户详情
export const userDetailByIdAPI = (id) => {
  // GET传参是params，POST是data
  return request({
    method: 'GET',
    // url: '/user/' + id,
    url: `/user/${id}`,
    // headers: {
    //   Authorization: getToken()
    // }
  })
}

// 编辑用户信息
export const userUpdataByIdAPI = (id, data) => {
  // GET传参是params，POST是data
  return request({
    method: 'POST',
    // url: '/user/' + id,
    url: `/user_update/${id}`,
    // headers: {
    //   Authorization: getToken()
    // },
    data: data
  })
}

//关注用户
export const userfollowsAPI = (id) => {
  // GET传参是params，POST是data
  return request({
    method: 'GET',
    url: `/user_follows/${id}`,
  })
}
// 取消关注
export const userUnFollowsByIdAPI = (id) => {
  // GET传参是params，POST是data
  return request({
    method: 'GET',
    url: `/user_unfollow/${id}`,
  })
}
// 获取关注用户列表
export const getUserFollowsAPI = () => {
  return request({
    method: 'GET',
    url: `/user_follows`,
  })
}

// 获取收藏文章列表
export const getUserStarAPI = () => {
  return request({
    method: 'GET',
    url: `/user_star`,
  })
}
// 用户评论列表
export const getUserCommentsAPI = () => {
  return request({
    method: 'GET',
    url: `/user_comments`,
  })
}